package com.aiowang.springboot.dynamic.activemq.utils;


import com.aiowang.springboot.dynamic.activemq.config.DynamicActivemqProperties;

import java.util.Map;

/**
 * @author aiowang
 * @date 2020-03-18 20:31
 */
public class ToolsUtils {


    /**
     * 转换类
     * @param key 服务名
     * @param map map对象
     * @return DynamicActivemqProperties 对象类
     */
    public static DynamicActivemqProperties mapToDAP(String key, Map<String,String> map){

        DynamicActivemqProperties dynamicActivemqProperties = new DynamicActivemqProperties();
        dynamicActivemqProperties.setActivemqName(key);
        dynamicActivemqProperties.setBrokerUrl(map.get("brokerUrl"));
        dynamicActivemqProperties.setClientIDPrefix(map.get("clientIDPrefix"));
        dynamicActivemqProperties.setUser(map.get("user"));
        dynamicActivemqProperties.setPassword(map.get("password"));
        dynamicActivemqProperties.setSingle(("true").equals(map.get("single"))?true:false);
        dynamicActivemqProperties.setQueueFactory(map.get("queue-factory"));
        dynamicActivemqProperties.setTopicFactory(map.get("topic-factory"));
        return dynamicActivemqProperties;
    }
}
